import { COUNTER_DECREMENT, COUNTER_INCREMENT } from '../constants'
// reducer 是一个函数，负责根据 action 的类型和 payload 返回相应的 state
export default function counter(state = 10, action) {
  switch (action.type) {
    case COUNTER_INCREMENT:
      return state + action.payload
    case COUNTER_DECREMENT:
      return state - action.payload
    default:
      return state
  }
}
